package com.dtagri.fjwlw.ui;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.widget.ListView;

import com.dtagri.fjwlw.R;
import com.dtagri.fjwlw.adapter.CheckAreaDlgAdapter;
import com.dtagri.fjwlw.bean.SmallArea;
import com.dtagri.fjwlw.widget.CommonDialog;

/**
 * 勾选小区对话框
 * 
 * @author wxjn
 * 
 */
public class ZCheckAreaDialog extends CommonDialog {

	private Context context;
	private ListView listview;
	private List<SmallArea> smallAreas = new ArrayList<SmallArea>();
	private CheckAreaDlgAdapter checkAreaDlgAdapter;

	public List<SmallArea> getSmallAreas() {
		return smallAreas;
	}

	public ZCheckAreaDialog(Context context, List<SmallArea> smallAreas) {
		this(context, R.style.dialog_common, smallAreas);
	}

	public ZCheckAreaDialog(Context context, int defStyle,
			List<SmallArea> smallAreas) {
		super(context, defStyle);
		this.context = context;
		this.smallAreas = smallAreas;

		setTitle("选择小区");
		setNegativeButton("取消", null);
		View inflate = getLayoutInflater().inflate(R.layout.layout_simple_list,
				null);
		setContent(inflate);
		initView(inflate);
	}

	private void initView(View view) {
		listview = (ListView) view.findViewById(R.id.listview);
		checkAreaDlgAdapter = new CheckAreaDlgAdapter(context, smallAreas);
		listview.setAdapter(checkAreaDlgAdapter);
	}
}
